<template>
    <div>
        <ul class="mui-table-view mui-table-view-chevron">
			<li class="mui-table-view-cell mui-media" v-for="item in newslist" :key='item.id'>
				<router-link class="mui-navigate-right" :to="'/home/newsinfo/'+ item.id">
					<img class="mui-media-object mui-pull-left" :src="item.img_url">
					<div class="mui-media-body">
						<h1>{{ item.title }}</h1>
						<p class='mui-ellipsis'>
                            <span>发表时间：{{ item.add_time }}</span>
                            <span>点击次数：{{  item.click }}</span>
                        </p>
					</div>
				</router-link>
			</li>
		</ul>
    </div>
</template>

<script>
import { Toast } from 'mint-ui'

export default {
    data(){
        return {
            newslist:[
                {
                    add_time:'2019-1-03 12:11:00',
                    click: 3 ,
                    id:1,
                    img_url:require('../../images/cbd.jpg'),
                    title:'CBD'
                },
                {
                    add_time:'2019-1-11 10:30:00',
                    click: 10 ,
                    id:2,
                    img_url:require('../../images/yuantiao.jpg'),
                    title:'远眺'
                }
            ]
        }
    },
    created(){
        this.getNewsList();
    },
    methods:{
        getNewsList(){
            this.$http.get('https://www.easy-mock.com/mock/5cf86de19b40a0058b942993/vue-001/newslist').then(result => {
                // console.log(result);
                if(result.status === 200){
                    this.newslist = result.body.data;
                }else{ 
                    Toast('获取商品列表失败')
                }
            })
        }
    }
    
}
</script>

<style lang="scss" scoped>
.mui-table-view{
    li{
        h1{ font-size: 15px;}
    }

    .mui-ellipsis{
        font-size: 10px;
        display: flex;
        justify-content: space-between;
    }

}

</style>
